<template>
  <div class="HomePage_top" style="z-index: 999">
    <Myphone></Myphone>
    <div class="btn-header">
      <i class="yo-ico" @click="goBack">&#xeb1a;</i>
      <span v-show="hp_top">{{ user_name }}</span>
      <i class="yo-ico yo-ico-right" v-html="i_cont" @click="clickHandler"></i>
    </div>
  </div>
</template>
<script>
import Myphone from '@/components/myphone'
import moment from 'moment'
import Vue from 'vue';
import { Dialog,Toast } from 'vant';
Vue.use(Toast);
Vue.use(Dialog);
export default {
    props:{
        list:Object
    },
    components:{
        [Dialog.Component.name]: Dialog.Component,
    },
    data() {
        return {
            i_cont:"",
            user_name:"",
            sendList:null
        }
    },
    computed:{
       hp_top:function(){
           return this.list.hp_top
       }
    },
    components:{
        Myphone
    },
    mounted(){
       this.i_cont=this.list.i_cont
       this.user_name=this.list.user_name
    },
    methods:{
        goBack(){
            this.$router.back();
        },
        clickHandler(){
           if(this.i_cont==="&#xe62f;"){
                if( this.list.uploadListA.content!==""&&this.list.uploadListA.active_name!==""){
                this.sendList={
                ...this.list.uploadListA
            };
            this.sendList.active_minute=moment(new Date().getTime()).format('HH:mm:DD');
            this.sendList.active_time=moment(new Date().getTime()).format('YYYY-MM-DD');
            // console.log(this.sendList);
            Dialog.confirm({
                title: '确认发布',
                message: this.sendList.active_name,
                })
                .then(async () => {
                let a= await  this.$http.post('http://localhost:3001/acive',this.sendList)
                if(a.status===201){
                    Toast.success('发布成功,请到个人主页查看');
                    this.$router.go(0);
                }
                })
                .catch(() => {
                    Toast.success('发布失败');
                });
        }else{
            Toast.fail('请添加内容');
        }
           }
    }
}
}
</script>
<style lang="stylus" scoped>
.HomePage_top {
  width: 100%;
  border_1px(0 0 1px 0);
  background-color: rgba(255, 255, 255, 1);

  .btn-header {
    height: 0.6rem;
    display: flex;
    justify-content: space-around;
    margin: 0 0.2rem 0 0.14rem;

    i {
      flex: 37;
      font-weight: 700;
      color: #646464;
      font-size: 0.22rem;
      display: inline-block;
      line-height: 0.6rem;
      vertical-align: middle;
    }

    span {
      flex: 301;
      line-height: 0.6rem;
      font-size: 0.2rem;
      text-align: center;
    }

    .yo-ico-right {
      flex: 37;
      line-height: 0.6rem;
      text-align: right;
    }
  }
}
</style>